package leetcode

//997. 找到小镇的法官
func findJudge(n int, trust [][]int) int {
	inDegrees:=make([]int,n+1)
	outDegrees:=make([]int,n+1)
	for _,v:=range trust{
		outDegrees[v[0]]++
		inDegrees[v[1]]++
	}
	for i:=1;i<n+1;i++{
		if inDegrees[i]==n-1&&outDegrees[i]==0{
			return i
		}
	}
	return -1
}
//1629. 按键持续时间最长的键
func slowestKey(releaseTimes []int, keysPressed string) byte {
	max:=releaseTimes[0]
	maxbyte :=keysPressed[0]
	for i:=1;i<len(keysPressed);i++{
		diff:=releaseTimes[i]-releaseTimes[i-1]
		if diff>max{
			max=diff
			maxbyte=keysPressed[i]
		}else if diff==max&&keysPressed[i]>maxbyte{
				max=diff
				maxbyte=keysPressed[i]
		}
	}
	return maxbyte
}